
//
//  YYJLCommentCell.m
//  YuanyangJinlou
//
//  Created by mac004 on 2017/1/11.
//  Copyright © 2017年 suli19910309@qq.com. All rights reserved.
//

#import "YYJLCommentCell.h"
@interface YYJLCommentCell(){
    UIImageView * headerView;//头像
    UIImageView * headerViewC;//评论人头像
    UILabel     * styleLb;//消息类型
    UILabel     * name;//姓名
    UILabel     * nameC;//评论人姓名
    UIImageView * levelView;//等级
    UILabel     * placeLb;//职位
    UILabel     * timeLb;//时间
    UILabel     * contentLb;//评论内容
    UILabel     * replaceLbC;//回复内容
    UIImage     * headerImg;
}
@end
@implementation YYJLCommentCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self =[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatUI];
    }
    return self;
}
-(void)creatUI{
    //头像
    headerImg=[UIImage imageNamed:@"touxiang2-80x80"];
    headerView=[[UIImageView alloc]initWithFrame:CGRectMake(12*PER_WIDTH, 15*PER_HEIGHT, headerImg.size.width*PER_WIDTH, headerImg.size.height*PER_WIDTH)];
    headerView.layer.cornerRadius=headerView.height/2;
    headerView.layer.masksToBounds=YES;
    headerView.image=headerImg;
    [self.contentView addSubview:headerView];
    
    //姓名
    name=[MyControl createLabelWithFrame:CGRectMake(headerView.right+10*PER_WIDTH, 20*PER_HEIGHT, 50, 15*PER_HEIGHT) Font:15 Text:@"李默尔"];
    name.textColor=UIColorFromHex(0x333333);
    [self.contentView addSubview:name];
    
    //消息类型
    styleLb=[MyControl createLabelWithFrame:CGRectMake(name.right+10*PER_WIDTH, name.top+1*PER_HEIGHT, 80*PER_WIDTH, 12) Font:12 Text:@"赞了话题"];
    styleLb.textColor=UIColorFromHex(0x999999);
    [self.contentView addSubview:styleLb];
    
    //等级
    UIImage * levelImg = [UIImage imageNamed:@"1"];
    levelView=[[UIImageView alloc]initWithFrame:CGRectMake(name.left, name.bottom+10*PER_HEIGHT, levelImg.size.width*PER_WIDTH, levelImg.size.height*PER_HEIGHT)];
    levelView.image=levelImg;
    [self.contentView addSubview:levelView];
    
    //职位
    placeLb=[MyControl createLabelWithFrame:CGRectMake(levelView.right+10*PER_WIDTH, name.bottom+10*PER_HEIGHT, 30, 12) Font:12 Text:@"店长"];
    placeLb.textColor=UIColorFromHex(0x333333);
    [self.contentView addSubview:placeLb];
    
    //回复按钮
    //1.
    UILabel * replaceLb =[MyControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH-12*PER_WIDTH-28*PER_WIDTH, 20*PER_HEIGHT, 28*PER_WIDTH, 14*PER_HEIGHT) Font:14 Text:@"回复"];
    replaceLb.textColor=TINK_COLOR;
    [self.contentView addSubview:replaceLb];
    //2.
    UIImage * replaceImg=[UIImage imageNamed:@"ico_huifu"];
    
    UIImageView*replaceView=[[UIImageView alloc]initWithFrame:CGRectMake(replaceLb.left-6*PER_WIDTH-replaceImg.size.width*PER_WIDTH, replaceLb.top, replaceImg.size.width*PER_WIDTH, replaceImg.size.height*PER_HEIGHT)];
    replaceView.image=replaceImg;
    [self.contentView addSubview:replaceView];
    //3.
    UIButton * replaceBtn = [MyControl createButtonWithFrame:CGRectMake(replaceView.left, replaceView.top, replaceView.width+6*PER_WIDTH +replaceLb.width,replaceLb.height) ImageName:@"" Target:self Action:@selector(replace) Title:@""];
    replaceBtn . backgroundColor=[UIColor clearColor];
    [self.contentView addSubview:replaceBtn];
    
    //时间
    timeLb=[MyControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH-12*PER_WIDTH-200*PER_WIDTH, replaceBtn.bottom+10*PER_HEIGHT, 200*PER_WIDTH, 12*PER_HEIGHT) Font:12 Text:@"一小时前"];
    timeLb.textColor=UIColorFromHex(0x999999);
    timeLb.textAlignment=NSTextAlignmentRight;
    [self.contentView addSubview:timeLb];
    
    //评论内容
    contentLb=[MyControl createLabelWithFrame:CGRectMake(headerView.left, levelView.bottom+15*PER_HEIGHT, SCREEN_WIDTH-24*PER_WIDTH, 15*PER_HEIGHT) Font:15 Text:@"的确,每颗珍珠都要一种独特的韵味"];
    contentLb.textColor=BLACK_COLOR;
    [self.contentView addSubview:contentLb];
    

}
-(void)setIsReplace:(BOOL)isReplace{
    _isReplace=isReplace;
    if (isReplace) {
        UIView*bgView=[[UIView alloc]initWithFrame:CGRectMake(20*PER_WIDTH, contentLb.bottom+10*PER_HEIGHT, SCREEN_WIDTH-40*PER_WIDTH, 120)];
        bgView.backgroundColor=UIColorFromHex(0xf2f2f2);
        [self.contentView addSubview:bgView];
        
        headerViewC=[[UIImageView alloc]initWithFrame:CGRectMake(12*PER_WIDTH, 15*PER_HEIGHT, headerImg.size.width*PER_WIDTH, headerImg.size.height*PER_WIDTH)];
        headerViewC.layer.cornerRadius=headerView.height/2;
        headerViewC.layer.masksToBounds=YES;
        headerViewC.image=headerImg;
        [bgView addSubview:headerViewC];
        
        UILabel * replace1=[MyControl createLabelWithFrame:CGRectMake(headerViewC.right+ 20*PER_HEIGHT, 20*PER_HEIGHT, bgView.width-headerViewC.right-10*PER_WIDTH, 14*PER_HEIGHT) Font:14 Text:@"流星星: 努力,一起共勉!" Color:BLACK_COLOR];
        [bgView addSubview:replace1];
        
        UILabel * time1=[MyControl createLabelWithFrame:CGRectMake(replace1.left, replace1.bottom+10*PER_HEIGHT, 100, 12*PER_HEIGHT) Font:12 Text:@"12-01  15:15" Color:FEELT_COLOR];
        [bgView addSubview:time1];
        
        UIImage*img=[UIImage imageNamed:@"ico_huifupinglun"];//12*12
        UIImageView * img1=[[UIImageView alloc]initWithFrame:CGRectMake(time1.right+10*PER_WIDTH, time1.top, img.size.width*PER_WIDTH, img.size.width*PER_WIDTH)];
        img1.image=img;
        [bgView addSubview:img1];
        
        
        UIImageView * head1=[[UIImageView alloc]initWithFrame:CGRectMake(headerViewC.left+ 12*PER_WIDTH,headerViewC.bottom+ 18*PER_HEIGHT, headerImg.size.width*PER_WIDTH, headerImg.size.height*PER_WIDTH)];
        head1.layer.cornerRadius=headerView.height/2;
        head1.layer.masksToBounds=YES;
        head1.image=headerImg;
        [bgView addSubview:head1];
        
        UILabel * replace2=[MyControl createLabelWithFrame:CGRectMake(head1.right+ 10*PER_HEIGHT,time1.bottom +25*PER_HEIGHT, bgView.width-headerViewC.right-10*PER_WIDTH, 14*PER_HEIGHT) Font:14 Text:@"流星星: 努力,一起共勉!" Color:BLACK_COLOR];
        [bgView addSubview:replace2];
        
        UILabel * time2=[MyControl createLabelWithFrame:CGRectMake(replace2.left, replace2.bottom+10*PER_HEIGHT, 100, 12*PER_HEIGHT) Font:12 Text:@"12-01  15:15" Color:FEELT_COLOR];
        [bgView addSubview:time2];
        UIImageView * img2=[[UIImageView alloc]initWithFrame:CGRectMake(time2.right+10*PER_WIDTH, time2.top, img.size.width*PER_WIDTH, img.size.width*PER_WIDTH)];
        img2.image=img;
        [bgView addSubview:img2];
        
    }
}

@end
